#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define y1 y_alpha_1

using namespace std;

using ll = long long;
using db = double;
using vec = vector<int>;
using pii = pair<int,int>;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-',ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48),ch = getchar();
	return f ? -x : x;
}

const int N = 5e4 + 10;
const int M = 1e5 + 10;

int B,n,m,Q,tot;
struct edge { int u,v,a,b,id; } e[M],q[N],sq[N];
bool ans[N];

namespace D {
	int fa[N],ma[N],mb[N],siz[N];
	int top;
	struct opt { int u,v,mxa,mxb,sz; } o[N];
	int gf(int x) { return x == fa[x] ? x : gf(fa[x]); }
	void reset() { top = 0; for(int i = 1;i <= n;i++) fa[i] = i,ma[i] = mb[i] = - 1, siz[i] = 1; }
	void merge(int x,int y,int mxa,int mxb,int tp = 0) {
		x = gf(x) , y = gf(y); if(siz[x] > siz[y]) swap(x,y);
		if(tp) o[++top] = (opt) { x,y,ma[y],mb[y],siz[y] }; if(x ^ y) fa[x] = y, ma[y] = max(ma[y],ma[x]), mb[y] = max(mb[y],mb[x]), siz[y] += siz[x];
		ma[y] = max(ma[y],mxa); mb[y] = max(mb[y],mxb);
	}
	void undo() {
		while(top) {
			int x = o[top].u,y = o[top].v,mxa = o[top].mxa,mxb = o[top].mxb,sz = o[top].sz;
			ma[y] = mxa; mb[y] = mxb; siz[y] = sz; fa[x] = x; top--;
		}
	}
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,m = in; B = sqrt(m * log2(n));
	for(int i = 1;i <= m;i++) e[i].u = in,e[i].v = in,e[i].a = in,e[i].b = in,e[i].id = i;
	Q = in; for(int i = 1;i <= Q;i++) q[i].u = in,q[i].v = in,q[i].a = in,q[i].b = in,q[i].id = i;
	sort(e + 1,e + m + 1,[](edge a,edge b) { return a.a < b.a; });
	for(int st = 1;st <= m;st += B) {
		D :: reset(); tot = 0;
		for(int i = 1;i <= Q;i++) if(q[i].a >= e[st].a && (st + B > m || q[i].a < e[st + B].a)) sq[++tot] = q[i];
		if(st > 1) sort(e + 1,e + st,[](edge a,edge b) { return a.b < b.b; });
		sort(sq + 1,sq + tot + 1,[](edge a,edge b) { return a.b < b.b; });
		for(int i = 1,j = 1;i <= tot;i++) {
			while(j < st && e[j].b <= sq[i].b) D :: merge(e[j].u,e[j].v,e[j].a,e[j].b),j++;
			for(int k = st;k < st + B && k <= m;k++) {
				if(e[k].a <= sq[i].a && e[k].b <= sq[i].b)
					D :: merge(e[k].u,e[k].v,e[k].a,e[k].b,1);
			}
			sq[i].u = D :: gf(sq[i].u) , sq[i].v = D :: gf(sq[i].v);
			ans[sq[i].id] = (sq[i].u == sq[i].v && D :: ma[sq[i].u] == sq[i].a && D :: mb[sq[i].u] == sq[i].b);
			D :: undo();
		}
	}
	for(int i = 1;i <= Q;i++) puts(ans[i] ? "Yes" : "No");
	return 0;
}
